# -*- coding: utf-8 -*-

from django.shortcuts import render_to_response, get_object_or_404
from django.http import Http404, HttpResponseRedirect, HttpResponse
from django.template import RequestContext

from datetime import datetime
from collections import defaultdict
from models import *

from ds import db
from common import util

def list(request):
    prjs = [t for t in db.project.find()]

    return render_to_response("project/project.html", {
        "projects":prjs,
    })

@util.jsonresp('id')
@util.bind(dict, 'name', 'desc', 'priority', 'owner', status='todo', add_time=datetime.now())
def add(request, inst):
    return str(db.project.insert(inst))